﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MastePage/SubEmptyMaster.Master" AutoEventWireup="true" CodeBehind="ScheduleEdit.aspx.cs" Inherits="BySoft.Web.Site.StockManage.ScheduleEdit" %>

<%@ MasterType VirtualPath="~/MastePage/SubEmptyMaster.master" %>
<%@ Register Assembly="OneSoft.Web" Namespace="OneSoft.Web.UI.WebControls" TagPrefix="asp" %>
<%@ Register Assembly="BySoft.Web.Controls" Namespace="BySoft.Web.Controls" TagPrefix="cc1" %>
<asp:Content ID="cphHeadContent" runat="server" ContentPlaceHolderID="HeadPlace">
    <script type="text/javascript">
        $(function () {
            $("#tabs").tabs({ show: function (event, ui) { iframeAutoFit(); } });
        })

        function CheckNumWithDotOne(txtBox) {
            if (txtBox != null && txtBox.value != "") {
                var numFormat = /(^[0-9]\d{0,9}(\.\d{0,4})?$)/;
                var text = txtBox.value;
                if (!numFormat.test(text)) {
                    txtBox.value = 0;
                }
            }
        }

        function FunAdd() {
            var ScheduleID = document.getElementById('<%=txtScheduleID.ClientID%>').value;
            if (ScheduleID == "") {
                ShowTopAlert("提示", "表单号码为空！");
                return false;
            }
            ShowTopDialog('选择产品', '../ComPage/QueryMProductBySchedule.aspx?ScheduleID='+ScheduleID, 'Fill();', 1000, 600); return false;
        }
        function Fill() {
            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                $("#<%=btnHidden.ClientID%>").click();
            }
            setCookie(dialogReturn_key, "");
        }


        function OpenMachine(ProcessID, ScheduleProcessID) {
            var ScheduleID = document.getElementById('<%=txtScheduleID.ClientID%>').value;
            if (ScheduleID == "") {
                ShowTopAlert("提示", "表单号码为空！");
                return false;
            }
            ShowTopDialog('选择机台', '../ComPage/QueryMachineByProcess.aspx?processid=' + ProcessID + '&scheduleprocessid=' + ScheduleProcessID + '&scheduleid=' + ScheduleID, 'FillC();', 1000, 600); return false;
        }
        function OpenMat(obj) {
            var pre = obj.id.replace("lbtnProjectName", "");
            var nums = $("#" + pre + "txtScheduleNum").val() * 1;
            var WorkOrderNo = $("#" + pre + "lblWorkOrderNo").text();
            ShowTopDialog('查看原料', '../ComPage/ViewScheduleMat.aspx?workorderno=' + WorkOrderNo + "&nums=" + nums, 'FillView();', 1000, 600); return false;
        }
    </script>
</asp:Content>
<asp:Content ID="cphContent" runat="server" ContentPlaceHolderID="EmptyMasteCPH">
    <h1 class="tit">库存管理 >> <a href="ScheduleList.aspx">生产排程>></a> 编辑</h1>
    <br />
    <div class="tableStyle2">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table border="0" cellspacing="0" cellpadding="0" style="text-align: left; width: 100%"
                    id="tBase" runat="server">
                     <tr>
                        <th class="left2">表单号码</th>
                        <td class="right2">
                            <asp:TextBox ID="txtScheduleID" runat="server" CssClass="lblreadonly"></asp:TextBox></td>
                        <th class="left2">日期：
                        </th>
                        <td class="right2">
                            <input class="Wdate" id="cpBillDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" runat="server" type="text"></input>
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ControlToValidate="cpBillDate" ID="RequiredFieldValidator2" Display="None" runat="server" ErrorMessage="请选择日期" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th class="left2">生产日期（起）：</th>
                        <td class="right2">
                            <input class="Wdate" id="txtFromDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" runat="server" type="text"></input>
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ControlToValidate="txtFromDate" ID="RequiredFieldValidator1" Display="None" runat="server" ErrorMessage="请选择生产日期（起）" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                        </td>
                        <th class="left2">生产日期（迄）：</th>
                        <td class="right2">
                            <input class="Wdate" id="txtEndDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" runat="server" type="text"></input>
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ControlToValidate="txtFromDate" ID="RequiredFieldValidator3" Display="None" runat="server" ErrorMessage="请选择生产日期（迄）" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="tableStyle">
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">产品明细</a></li>
                <li><a href="#tabs-2">加工工序明细</a></li>
            </ul>
            <div id="tabs-1">
                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                    <ContentTemplate>
                        <div style="width: 100%; padding-bottom: 10px">
                            <div align="right">
                                <label class="btnStylec png_bg">
                                    <asp:Button ID="btnAdd" runat="server" Text="新增" OnClientClick="FunAdd()" />
                                    <asp:Button ID="btnHidden" runat="server" CssClass="Hidden" OnClick="btnHidden_Click"/>
                                </label>
                            </div>
                        </div>
                        <div>
                            <asp:SGridView runat="server" ID="grdResult" Width="100%" ShowActionToolBar="false"
                                AutoGenerateColumns="false" AllowCascade="false" OnRowDataBound="grdResult_RowDataBound" OnRowCommand="grdResult_RowCommand">
                                <Columns>
                                    <asp:TemplateField HeaderText="排程产品明细编号" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblScheduleDetailID" Text='<%#Eval("ScheduleDetailID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="计划单编号" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblPlanID" Text='<%#Eval("PlanID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="序号">
                                        <ItemTemplate>
                                            <asp:Label ID="lblOrderNum" Text='<%#Eval("OrderNum") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="制单号码">
                                        <ItemTemplate>
                                            <asp:Label ID="lblWorkOrderNo" Text='<%#Eval("WorkOrderNo") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="订购公司">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCustomerName" runat="server" Text='<%#Eval("CustomerName") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="送货公司">
                                        <ItemTemplate>
                                            <asp:Label ID="lblSendCustomerName" Text='<%#Eval("SendCustomerName") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="产品编号">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProductID" Text='<%#Eval("ProductID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="产品名称">
                                        <ItemTemplate>
                                            <asp:LinkButton style="color:dodgerblue;text-decoration:underline;cursor:pointer;" OnClientClick='OpenMat(this)' ID="lbtnProjectName" runat="server">
                                                <asp:Label ID="lblProductName" Text='<%#Eval("ProductName") %>' runat="server"></asp:Label>
                                            </asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="规格">
                                        <ItemTemplate>
                                            <asp:Label ID="lblSpecifications" Text='<%#Eval("Specifications") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="外径">
                                        <ItemTemplate>
                                            <asp:Label ID="lblOutSide" Text='<%#Eval("OutSide") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="内径">
                                        <ItemTemplate>
                                            <asp:Label ID="lblInSide" Text='<%#Eval("InSide") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="单位">
                                        <ItemTemplate>
                                            <asp:Label ID="lblUnit" Text='<%#Eval("Unit") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="订单数量">
                                        <ItemTemplate>
                                            <asp:Label ID="lblOrderNums" Text='<%#Eval("OrderNums") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="计划数量">
                                        <ItemTemplate>
                                            <asp:Label ID="lblPlanNum" Text='<%#Eval("PlanNum") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="剩余数量">
                                        <ItemTemplate>
                                            <asp:Label ID="lblLastNum" Text='<%#Eval("LastNum") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="排程数量">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtScheduleNum" Text='<%#Eval("ScheduleNum") %>' runat="server" onkeyup="CheckNumWithDotOne(this);"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="备注">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtRemark" Text='<%#Eval("Remark") %>' runat="server"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="预计入库时间">
                                        <ItemTemplate>
                                            <asp:TextBox  class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" ID="txtExpectInStockDate" Text='<%#Eval("ExpectInStockDate") %>' runat="server"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <HeaderStyle Width="35px" />
                                        <HeaderTemplate>
                                            删除
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:ImageButton ImageUrl="../App_Themes/Common_CSS/images/delete_small.gif" runat="server"
                                                ID="ibtnDel" />
                                            <asp:Button ID="btnDel" runat="server" CssClass="Hidden" CommandArgument='<%#Eval("WorkOrderNo") %>'
                                                CommandName="del" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:SGridView>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <div id="tabs-2">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <div style="width: 100%; padding-bottom: 10px">
                            <div align="right"></div>
                        </div>
                        <div>
                            <asp:SGridView runat="server" ID="grdProcess" Width="100%" ShowActionToolBar="false"
                                AutoGenerateColumns="false" AllowCascade="false" OnRowDataBound="grdProcess_RowDataBound">
                                <Columns>
                                    <asp:TemplateField HeaderText="ScheduleProcessID" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblScheduleProcessID" Text='<%#Eval("ScheduleProcessID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="工序编号">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProcessID" Text='<%#Eval("ProcessID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="工序名称">
                                        <ItemTemplate>
                                            <a style="color:dodgerblue;text-decoration:underline;cursor:pointer;" onclick='OpenMachine("<%#Eval("ProcessID") %>","<%#Eval("ScheduleProcessID") %>")'><asp:Label ID="lblProcessName" Text='<%#Eval("ProcessName") %>' runat="server"></asp:Label></a>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="生产顺序">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtOrderNum" Text='<%#Eval("OrderNum") %>' onkeyup="CheckNumWithDotOne(this)" runat="server"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="是否检验">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkIsCheck" runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="是否委外">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkIsOutSource" runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:SGridView>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
    <div class="controlBar" align="center">
        <table cellpadding="0" cellspacing="0" style="width: 300px; margin: 0 auto;">
            <tr>
                <td colspan="4">
                    <label class="btnStyleb png_bg">
                        <asp:Button ID="btnSubmit" runat="server" Text="确定" OnClick="btnSubmit_Click"
                            class="png_bg" />
                    </label>
                    <label class="btnStylec png_bg">
                        <input type="button" id="Button2" value="返回" runat="server" onclick="window.location = 'ScheduleList.aspx'"
                            class="png_bg" />
                    </label>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>